/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

package com.openbrew.openbrewrf.views;

import java.io.Serializable;
import java.util.Date;
import javax.persistence.Basic;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;
import javax.validation.constraints.NotNull;
import javax.xml.bind.annotation.XmlRootElement;

/**
 *
 * @author dchapman
 */
@Entity
@Table(name = "SalesOrder")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "SalesOrderView.findAll", query = "SELECT s FROM SalesOrderView s"),
    @NamedQuery(name = "SalesOrderVew.getAllUnExported", query = "SELECT s FROM SalesOrderView s WHERE s.exported = false"),
    @NamedQuery(name = "SalesOrderVew.getAllExported", query = "SELECT s FROM SalesOrderView s WHERE s.exported = true")})
public class SalesOrderView implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Basic(optional = false)
    @Column(name = "SOId")
    private Integer sOId;
    @Basic(optional = false)
    @NotNull
    @Column(name = "SODate")
    @Temporal(TemporalType.TIMESTAMP)
    private Date sODate;
    @Basic(optional = false)
    @NotNull
    @Column(name = "exported")
    private boolean exported;
    @JoinColumn(name = "SOCust", referencedColumnName = "CId")
    @ManyToOne(optional = false)
    private CustomerView sOCust;

    public SalesOrderView() {
    }

    public SalesOrderView(Integer sOId) {
        this.sOId = sOId;
    }

    public SalesOrderView(Integer sOId, Date sODate, boolean exported) {
        this.sOId = sOId;
        this.sODate = sODate;
        this.exported = exported;
    }

    public Integer getsOId() {
        return sOId;
    }

    public void setsOId(Integer sOId) {
        this.sOId = sOId;
    }

    public Date getsODate() {
        return sODate;
    }

    public void setsODate(Date sODate) {
        this.sODate = sODate;
    }

    public boolean isExported() {
        return exported;
    }

    public void setExported(boolean exported) {
        this.exported = exported;
    }

    public CustomerView getsOCust() {
        return sOCust;
    }

    public void setsOCust(CustomerView sOCust) {
        this.sOCust = sOCust;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (sOId != null ? sOId.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof SalesOrderView)) {
            return false;
        }
        SalesOrderView other = (SalesOrderView) object;
        if ((this.sOId == null && other.sOId != null) || (this.sOId != null && !this.sOId.equals(other.sOId))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "com.openbrew.openbrewrf.SalesOrderView[ sOId=" + sOId + " ]";
    }
}
